<?php
/**
 * Create by 11li
 * Date 2020/2/26
 * Time 16:44
 * 快递100
 */

namespace app\common\library;


class Kuaidi
{
	private static $instance;
	
	private $subscriptionKey;
	private $key;
	private $customer;
	private $aiKey;
	private $orderKey;
	private $secret;
	private $queryUrl;
	
	private function __construct()
	{
		$config = config('kuaidi');
		$this->subscriptionKey = $config['subscription_key'];
		$this->key = $config['key'];
		$this->customer = $config['customer'];
		$this->aiKey = $config['ai_key'];
		$this->orderKey = $config['order_key'];
		$this->secret = $config['secret'];
		$this->queryUrl = $config['query_url'];
	}
	
	public static function getInstance() {
		if(!self::$instance) {
			self::$instance = new self();
		}
		
		return self::$instance;
	}
	
	
	public function query($code, $shippingNo) {
		$url = $this->queryUrl.'?id=' . $this->key .'&com='. $code .'&nu='.$shippingNo;
		$result = curl_get_info($url);
		dump($result);die;
		$data = str_replace("\"",'"',$result );
		$data = json_decode($data,true);
	}
}